package com.x.client.bean

import android.os.Parcel
import android.os.Parcelable
import com.google.gson.annotations.SerializedName


/**
 *  Creator : GG
 *  Time    : 2017/12/1
 *  Mail    : gg.jin.yu@gmail.com
 *  Explain :
 */

data class Province(
        @SerializedName("provinceCode") var provinceCode: String? = "", //00010001
        @SerializedName("provinceId") var provinceId: String? = "", //110000
        @SerializedName("provinceInitial") var provinceInitial: String? = "", //BJS
        @SerializedName("provinceName") var provinceName: String? = "", //北京市
        @SerializedName("provincePinyin") var provincePinyin: String? = "", //beijingshi
        @SerializedName("provinceSeq") var provinceSeq: Int? = 0, //1
        @SerializedName("provinceState") var provinceState: Int? = 0, //1
        var status: Boolean = false
) : Parcelable {
    constructor(source: Parcel) : this(
            source.readString(),
            source.readString(),
            source.readString(),
            source.readString(),
            source.readString(),
            source.readValue(Int::class.java.classLoader) as Int?,
            source.readValue(Int::class.java.classLoader) as Int?,
            1 == source.readInt()
    )

    override fun describeContents() = 0

    override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
        writeString(provinceCode)
        writeString(provinceId)
        writeString(provinceInitial)
        writeString(provinceName)
        writeString(provincePinyin)
        writeValue(provinceSeq)
        writeValue(provinceState)
        writeInt((if (status) 1 else 0))
    }

    companion object {
        @JvmField
        val CREATOR: Parcelable.Creator<Province> = object : Parcelable.Creator<Province> {
            override fun createFromParcel(source: Parcel): Province = Province(source)
            override fun newArray(size: Int): Array<Province?> = arrayOfNulls(size)
        }
    }
}